<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>中国福利彩票</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
	<link rel="icon" href="images/favicon.png" type="image/x-icon"/>
<script src="js/jquery-1.7.2.min.js"></script>

</head>

<body>
	<div class="Header">
    	<div class="width1200">
        	<div class="left H_logo"><a href="MemberCenter.html"><img src="images/logo.png" width="200" /></a></div>
            <div class="right H_right">欢迎  <a href="MemberCenter.html"><span id="userName"></span></a> <a href="Login.html">注销！</a></div>
            <div class="clear"></div>
        </div>
    </div>
	
    <div class="width1200">
    	<div class="I_main">
            <div class="left IM_left">
            	<div class="IM_T1">查询服务</div>
                <div class="IML_two">
                	<ul>
						<li><a href="Xzhtz.html" style="border:none;"><img src="images/Limg1.png" width="16" />交易记录查询</a></li>
						<li><a href="Xzjls.html"><img src="images/Limg1.png" width="16" />资金记录查询</a></li>
                    </ul>
                </div>
                <div class="IM_T2">个人设置</div>
                <div class="IML_two">
                	<ul>
                    	<li class="fist"><a href="BankCard.html"><img src="images/Limg2.png" width="16" />银行卡变更</a></li>
                        <li><a href="PhoneNumber.html"><img src="images/Limg3.png" width="16" />手机号变更</a></li>
                        <li><a href="Yuecx.html"><img src="images/Limg4.png" width="16" />余额查询</a></li>
                        <li><a href="PassWord.html"><img src="images/Limg5.png" width="16" />修改密码</a></li>
                        <li><a href="App.html"><img src="images/Limg6.png" width="16" />APP下载</a></li>
                    </ul>
                </div>
            </div>
            <div class="right IM_right">
            	
                <div class="IMR_title">
                	<img src="images/RTb.jpg" width="5" />银行卡变更
                </div>
                
                <div class="IM_Rbig">
                	<div class="N_PassWord">
                   	  <table width="100%" border="0" cellspacing="5" cellpadding="0">
                          <!--<tr>-->
                            <!--<td width="10%" align="left">选择银行：</td>-->
                            <!--<td width="90%">-->
                            	<!--<div class="NBC_select">-->
                                	<!--<select name="bank" id="bank">-->

                                    <!--</select>-->
                                <!--</div>-->
                            <!--</td>-->
                          <!--</tr>-->
                          <tr>
                            <td width="10%" align="left">区域归属地：</td>
                            <td width="90%">
                            	<div class="NAP_select" style="display: inline-block;">
                                	<select name="homeOwnership" id="homeOwnership"></select>
                                </div>
                            	<div class="NAP_select" style="display: inline-block;">
									<select name="homeOwnershipcity" id="homeOwnershipcity"></select>
                                </div>
                            </td>
                          </tr>
                          <tr>
                            <td align="left">银行卡号：</td>
                            <td><input type="text" class="NPW_text" id="bankCard"/></td>
                          </tr>
                          <tr>
                            <td align="left">&nbsp;</td>
                            <td><input type="submit" value="确认" class="NAP_but"  onclick="sureBtn()"/></td>
                          </tr>
                        </table>
                  </div>
              </div>
                
            </div>
            <div class="clear"></div>
    	</div>
    </div>
    
    <div class="Footer">
    	<div class="width1200">
        	<div class="left">版权所有：中国福利彩票发行管理中心    网站主办：中国福利彩票发行管理中心</div>
            <div class="right"><img src="images/Flogo.png" width="110" /></div>
            <div class="clear"></div>
        </div>
    </div>
</body>
<script type="text/javascript">
var accountId="";
var token="";
var channelId="";
var pwd="";
jQuery(document).ready(function($){
	$('#userName').html(getCookie("username"));
	accountId = getCookie("accountId");
	token = getCookie("token");
	channelId = getCookie("channelId");
	pwd = getCookie("pwd");
	//调用接口查询 银行类别
//	$.ajax({
//		url : "../../api/CrmSystem/para/swiftcode",
//		async:false,
//		type : "GET",
//		herder:{
//			'Accept':'application/json',
//			'Content-Type':'application/json'
//		},
//		dataType:"json",
//		contentType:"application/json",
//		error:function(XMLHttpRequest, textStatus, errorThrown){
//			alert(errorThrown);
//		},
//		success: function(data, textStatus){
//			document.getElementById("bank").options.length=0;
//// 			var data = "[{\"swiftCode\": \"AK\",\"swiftName\": \"安徽省农村信用社\",\"marks\": null},{\"swiftCode\": \"AZ\",\"swiftName\": \"长安银行\",\"marks\": null}]";
//// 			var obj = eval("("+data+")");
//			for(var i=0;i<data.length;i++){
//				document.getElementById("bank").options.add(new Option(data[i].swiftName,data[i].swiftCode));
//			}
//		}
//	});
	
	//调用地区参数查询接口
	getFirstLevel();
	getSecondLevel($('#homeOwnership').val());
	
	//归属地第一级改变出发的事件
	$("#homeOwnership").change(function(){
		getSecondLevel($('#homeOwnership').val());
		});
});

function sureBtn(){
	//验证银行卡号
	if(!validateBankNum('bankCard')){
		return;
	}
  var para = {
		  	accountId:accountId,
		  	bankCard:$("#bankCard").val(),
			regionCode:$("#homeOwnership").val()+"_"+$("#homeOwnershipcity").val(),
			swiftCode:"AC",
			password:pwd,//该密码是登录后放入cookie中，已经加密，所以此处不需要再加密
			token:token,
			channelId:channelId
        };
	
	$.ajax({
		url : "../../api/CrmSystem/account/bankcardchange",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data: JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
// 			var obj = eval("("+data+")"); 
			if(data.success == true){
				window.location.href='BCWin.html';
			}else{
				alert("error:"+data.description);
				window.location.href='BCDown.html';
				return;
			}
		}		
	});
}
//获得归属地--第一级
function getFirstLevel(){
	$.ajax({
		url : "../../api/CrmSystem/para/region?pid=0",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnership").options.length=0;
// 			var obj = eval("("+data+")"); 
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnership").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}
//获得归属地--第二级
function getSecondLevel(pid){
	if(pid==null){
		pid=0;
	}
	$.ajax({
		url : "../../api/CrmSystem/para/region?pid="+pid+"",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnershipcity").options.length=0;
// 			var obj = eval("("+data+")"); 
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnershipcity").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}
</script>
<script src="js/SHA256.js"></script>
<script src="js/jsCallCookies.js"></script>
<script src="js/validation.js"></script>
</html>
